package com.ltx.blog_ltx.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebAppConfig implements WebMvcConfigurer {


    public MyWebAppConfig() {
        System.out.println("注册进来了=====================");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //md文件位置建立映射
        registry.addResourceHandler("/note/**").addResourceLocations("file:D:/note/");
        //图片位置建立映射
        registry.addResourceHandler("/assets/**") //虚拟url路径
                .addResourceLocations("file:D:/note/assets/"); //真实本地路径
        //头像位置建立映射
        registry.addResourceHandler("/userimg/**") //虚拟url路径
                .addResourceLocations("file:D:/note/userimg/"); //真实本地路径
    }
}